package io.renren.modules.cuttingcur.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.cuttingcur.dao.CuttingmachineCurdataDao;
import io.renren.modules.cuttingcur.entity.OldCuttinginfoEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.cuttingcur.entity.CuttingmachineCurdataEntity;
import io.renren.modules.cuttingcur.service.CuttingmachineCurdataService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-08-28 09:40:29
 */
@RestController
@RequestMapping("cuttingcur/cuttingmachinecurdata")
public class CuttingmachineCurdataController {
    @Autowired
    private CuttingmachineCurdataService cuttingmachineCurdataService;


    @GetMapping("getCuttingMachine")
    public List<CuttingmachineCurdataDao> getCuttingMachine(){
        return cuttingmachineCurdataService.getCuttingMachine();
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("cuttingcur:cuttingmachinecurdata:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = cuttingmachineCurdataService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 获取全部焊机
     */
    @GetMapping(value = "/listAll",produces = {"application/json;charset=UTF-8"})
    public List<CuttingmachineCurdataEntity> listAll(){
        return cuttingmachineCurdataService.listAll();
    }

    /**
     * 获取全部切割机
     */
    @GetMapping(value = "/listCuttinginfo",produces = {"application/json;charset=UTF-8"})
    public List<OldCuttinginfoEntity> listCuttinginfo(){
        return cuttingmachineCurdataService.listCuttinginfo();
    }

    /**
     * 更新设备
     */
    @PostMapping(value = "/updateByDeviceId",produces = {"application/json;charset=UTF-8"})
    public int updateByDeviceId(@RequestParam(value = "deviceId",required = false) String deviceId,@RequestParam(value = "deviceName",required = false) String deviceName,@RequestParam(value = "deviceType",required = false) String deviceType,@RequestParam(value = "deviceProfileName",required = false) String deviceProfileName,@RequestParam(value = "deviceProtocol",required = false) String deviceProtocol,@RequestParam(value = "createdTime",required = false) String createdTime){
        return cuttingmachineCurdataService.updateByDeviceId(deviceId,deviceName,deviceType,deviceProfileName,deviceProtocol,createdTime);
    }

    /**
     * 根据ID获取设备信息
     */
    @GetMapping(value = "/getCuttingInfoById",produces = {"application/json;charset=UTF-8"})
    public List<OldCuttinginfoEntity> getCuttingInfoById(@RequestParam(value = "deviceId",required = false) String deviceId){
        return cuttingmachineCurdataService.getCuttingInfoById(deviceId);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{no}")
    @RequiresPermissions("cuttingcur:cuttingmachinecurdata:info")
    public R info(@PathVariable("no") Integer no){
		CuttingmachineCurdataEntity cuttingmachineCurdata = cuttingmachineCurdataService.getById(no);

        return R.ok().put("cuttingmachineCurdata", cuttingmachineCurdata);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("cuttingcur:cuttingmachinecurdata:save")
    public R save(@RequestBody CuttingmachineCurdataEntity cuttingmachineCurdata){
		cuttingmachineCurdataService.save(cuttingmachineCurdata);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("cuttingcur:cuttingmachinecurdata:update")
    public R update(@RequestBody CuttingmachineCurdataEntity cuttingmachineCurdata){
		cuttingmachineCurdataService.updateById(cuttingmachineCurdata);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("cuttingcur:cuttingmachinecurdata:delete")
    public R delete(@RequestBody Integer[] nos){
		cuttingmachineCurdataService.removeByIds(Arrays.asList(nos));

        return R.ok();
    }

}
